#include "Js.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Js_classType = NULL;
VTable* Js_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Js defVal */
Js* Js_defVal(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Js.defVal not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Js_initType(void)
{
  if (Js_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Js_initVTable();
    Type* type = Type_new("Js", baseType, vtable, sizeof(Js), sizeof(JsVTable));
    Type_registerFieldImplementation(type, "defVal", Js_defVal, NULL);
    Js_classType = type;
    Js_initStatic();
  }
  return Js_classType;
}


VTable* Js_initVTable(void)
{
  if (Js_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(JsVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    Js_classVTable = vtable;
  }
  return Js_classVTable;
}


void Js_initStatic(void)
{
}
